#include "game.h"

void game(int rows, int cols, int count)
{
	char** mine = mine_creat(rows, cols);  //存放布置的雷
	char** show = show_creat(rows, cols);  //存放排查雷后的信息
	//初始化棋盘
	//mine数组初始全部设置为'0'
	//show数组初始全部设置为'*'
	InitBoard(mine, rows, cols, '0');
	InitBoard(show, rows, cols, '*');
	//打印棋盘
	//DisplayBoard(mine, ROW, COL);
	DisplayBoard(show, rows, cols);
	//布置雷
	SetMine(mine, rows, cols, count);
	//DisplayBoard(mine, ROW, COL);
	// 排查雷
	FindMine(mine, show, rows, cols, count);
}

int main()
{
	int input1 = 0;
	int input2 = 0;
	int ROW4 = 0;
	int COL4 = 0;
	int CustomMineCount = 0;
	srand((unsigned int)time(NULL));
	do 
	{
		menu1();
		printf("请选择:>");
		scanf("%d", &input1);
		if(input1 == 1)
		{
			do
			{
				system("cls");
				menu2();
				printf("请选择游戏难度:>");
				scanf("%d", &input2);
				switch (input2)
				{
				case 1:
					game(ROW1, COL1, EasyMineCount);
					break;
				case 2:
					game(ROW2, COL2, NormalMineCount);
					break;
				case 3:
					game(ROW3, COL3, DifficultyMineCount);
					break;
				case 4:
					printf("请输入雷区大小X Y和雷的数量:>");
					scanf("%d %d %d", &ROW4, &COL4, &CustomMineCount);
					game(ROW4, COL4, CustomMineCount);
					break;
				default:
					printf("输入错误，请重新输入\n");
				}
				Sleep(1000);
			}while(input2 != 1 && input2 != 2 && input2 != 3 && input2 != 4);	
		}
		else if(input1 == 0)
		{
			printf("退出游戏\n");
			break;
		}
		else
		{
			printf("输入错误，请重新输入\n");
		}
	} while (input1);
	return 0;
}
